home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-01 | 1.3 KB | 42 lines | [TEXT/PJMM] |
- { This code demonstrates how to use the Event Manager in order to }
- { get a single character from the keyboard like when you use }
- { the ReadKey function of Borland/Turbo Pascal. }
- { I myself use this program to determine the ASCII codes }
- { for special keys like the arrow keys. }
- { This code is Public Domain. You can do what you want with it, }
- { even sell it (although I don't think anyone will buy it :-) }
- { It should run both with CodeWarrior and THINK Pascal. No project is }
- { included because the project would be larger than the source code... }
- { If you have further questions, feel free to contact me }
- { Matthias Wuttke <wuttke@stein.teuto.de>}
-
- PROGRAM Keys;
-
- {$IFC UNDEFINED THINK_Pascal}
- USES
- Types, QuickDraw, Fonts, Windows, Events, Menus, TextEdit, Dialogs, Memory;
- {$ENDC}
-
- VAR
- ch: CHAR;
- evt: EventRecord;
- dummy: BOOLEAN;
-
- BEGIN
- {$IFC DEFINED THINK_PASCAL}
- ShowText;
- {$ENDC}
- REPEAT
- WriteLn('Press key, ''q'' for quit');
-
- REPEAT
- dummy := WaitNextEvent(keyDownMask, evt, 30, NIL);
- UNTIL evt.what = keyDown;
-
- ch := CHAR(BAnd(evt.message, charCodeMask));
- WriteLn('Character = ''', ch, '''');
- WriteLn('ASCII Code = ', BAnd(evt.message, charCodeMask) : 1);
- WriteLn('Virtual Key Code = ', BAnd(evt.message, keyCodeMask) : 1);
- WriteLn;
- UNTIL ch = 'q';
- END.